home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Micro Fox Tools / Numbering Systems Folder / About Numbering Systems next >
Encoding:
Text File  |  1995-12-03  |  5.6 KB  |  110 lines  |  [TEXT/ttxt]

  1. Numbering Systems   Version: 1.0    Nov 1995
  2. Author:     Jesse Carneiro
  3.             Micro Fox Software
  4. Address:    P.O. Box 14932 / Columbus, Ohio 43214-0932 / U.S.A.
  5. Internet:   microfox@kagi.com
  6. Web Page:   http://www.infinet.com/~microfox
  7. Shareware:  Send a postcard of your town, if you use it.
  8.  
  9.   The application Numbering Systems serves as a little utility for 
  10.   converting Decimal into Hexadecimal and Binary systems and vice 
  11.   versa.
  12.  
  13.   It shows the relationship of numbers in different systems. If you 
  14.   enter a decimal number and press the Enter or Return key, it will 
  15.   show on the Hexadecimal and Binary fields the representation of the 
  16.   entered number in those systems. Now if you press the Up or Down 
  17.   arrow keys, you’ll add or subtract one to that number and see its 
  18.   progression on the other fields. Notice how they change as you keep 
  19.   adding. Observe specially when you change from decimal 255 to 256.
  20.  
  21. Representing Numbers
  22.   We grew up quite familiar with the decimal numbering system. It 
  23.   seems so simple and quite adequate for what we need. However, when 
  24.   you start to learn programming, soon you’ll encounter other systems. 
  25.   At first these other numbering systems seem hard to understand (at 
  26.   least it seemed to me). But soon, you’ll understand the reason for 
  27.   their use.
  28.  
  29.   Computers, in general, use memory in which every byte (eight 
  30.   consecutive bits of zeros or ones) has a number associated with it. 
  31.   This number associated with every byte is said to be the address of 
  32.   that byte. A way to get to it. It starts at zero and move on up to 
  33.   however many megabytes of memory the user has installed on his 
  34.   machine. Pretty soon, using the decimal system, we would need many 
  35.   digits just to represent most of these bytes. If they are after the 
  36.   million byte mark, we will need six digits, etc., but using the 
  37.   hexadecimal numbering system, we could refer to these bytes with 
  38.   only a few digits, which is more convenient for programmers. On the 
  39.   other hand, sometimes a single byte (composed of 8 bits) could have 
  40.   some of its bits represent “flags," that is, the state of something 
  41.   (usually something that can be "ON" or "OFF" — often referred to as 
  42.   that bit being set [1] or not being set [0]).
  43.  
  44.   However, as the accompanying program, Numbering Systems, will show 
  45.   you, turning bits ON (changing them from zero to one) on a byte, 
  46.   will accommodate numbers only up to 255*. As such, the number 255 
  47.   represent all 8 bits being set to one. Add one more 1 to it and you 
  48.   will need another byte to represent it. Now we have a lot more bits 
  49.   to set. But soon you will run into a number limit when again, all of 
  50.   its bits are set to one. That number is 65535 in decimal, FFFF in 
  51.   hexadecimal or 1111 1111 1111 1111 in the binary system (Please 
  52.   Note: I am only referring to unsigned numbers, i.e., whole positive 
  53.   numbers). It represents the maximum number that can fit on two bytes. 
  54.   To represent larger numbers you need more bytes. It is obvious by 
  55.   now that the more bits (or bytes, if you group them) that you have 
  56.   to represent a number, the larger the number can be.
  57.  
  58.   Just like we group letters together to form words and then group 
  59.   words together to form sentences, and then group these to form 
  60.   paragraphs, etc., in computer programming we group 8 bits together 
  61.   and call it a Byte. We group two bytes and call it an Integer. We 
  62.   group four bytes and call it a Long Integer, group a mixture of 
  63.   these and you can call it a struct (in C) or a Record (in Pascal). 
  64.   In the programming languages Pascal, C, etc. that is the norm, but 
  65.   note that on some programming languages, an integer and a long 
  66.   integer may both have four bytes. They are used to accommodate 
  67.   numbers that can be fit within their limits.
  68.  
  69. Addresses
  70.   On the Macintosh, as with other computers, by virtue of its hardware 
  71.   design, the address of the bytes in memory is given 32 bits (4 bytes) 
  72.   for the representation of this address number. As such, you can fit 
  73.   a number as larger as decimal 4,294,967,296 (over four billion), 
  74.   FFFFFFFF in hexadecimal or 32 ones in binary. That would be the 
  75.   maximum number of bytes that such computer could access. It is an 
  76.   amazingly high number. Can you imagine 4 gigabytes of RAM memory?
  77.  
  78.   Just remember that all of this is only different ways to represent 
  79.   numbers. Decimal numbers makes more sense to us. Hexadecimal is very 
  80.   handy when working with a programming language. And zeros and ones 
  81.   is only what the CPU of a computer understands anyway. But they all 
  82.   represent the same thing: a number.
  83.  
  84.   I hope this helps a bit (no pun intended).
  85.  
  86.     Jesse Carneiro
  87.     Micro Fox Software
  88.     P.O. Box 14932
  89.     Columbus, OH 43214-0932
  90.     U.S.A.
  91.     Phone or Fax (614) 267-8638
  92.     Internet: microfox@kagi.com   (support, comments, etc.)
  93.     Web Page: http://www.infinet.com/~microfox
  94.  
  95.  
  96.   *PS - The program Numbering Systems only deals with positive numbers 
  97.         that can fit on an integer (two bytes). In reality, a byte can 
  98.         accommodate negative numbers also. The difference being that 
  99.         instead of the range being 0 to 255 as is on an unsigned integer, 
  100.         the range becomes –127 to +128 on a signed integer. The same 
  101.         treatment is given to signed long integer.
  102.  
  103.  
  104.   ©1995 Jesse Carneiro
  105.   The usual disclaimers apply: Jesse Carneiro and Micro Fox Software 
  106.   accept no responsibility for any incidental or consequential damage 
  107.   of any sort as a direct or indirect result of using this software.  
  108.   The software is provided “as-is,” and no warranties are made as to 
  109.   its fitness for a particular purpose.  I would be very interested to 
  110.   hear of any problems, though.